#!/bin/sh
echo "******************************* Step 1:   start install nginx **************************************"
echo "******************************* Step 2:   Install dependency package: gcc-c++,zlib,zlib-devel,openssl,openssl--devel,pcre,pcre-devel *********************************"
yum install -y gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel

echo "******************************* Step 4:   downloading nginx *******************************************************"
wget http://nginx.org/download/nginx-1.9.5.tar.gz
tar -xvf nginx-1.9.5.tar.gz
cd nginx-1.9.5

echo "****************************** Step 5:    configuring nginx,plz wait ************************************************"
./configure --prefix=/usr/local/nginx 

if [ $? -ne 0 ];then
echo "******************************************  configure failed ,please check it out! ******************************"
else
echo "******************************* Step 6:   make nginx, please wait for 20 minutes ********************************"
make
fi

if [ $? -ne 0 ];then
echo "*****************************************   make failed ,please check it out! ************************************"
else
echo "******************************* Step 7:    install nginx, please wait for 20 minutes ****************************"
make install
fi

chown -R  /usr/local/nginx
ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
/usr/local/nginx/sbin/nginx